var app = getApp()
let {
  getUserintegral,
  getCenterMenu
} = require("../../../api/api");
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    userInfo: {},
    userid: "",
    userintegral: ''
  },

  /**
   * 组件的方法列表
   */
  attached: function () {
    let that = this;
   
    var userid = wx.getStorageSync('userid')
    console.log(userid)

    wx.getSetting({
      success(res) {
        if (res.authSetting['scope.userInfo']) {
          wx.getUserInfo({
            success(res) {
              let userInfo = res.userInfo
              that.setData({
                userInfo: res.userInfo
              })
              console.log(userInfo)
            }
          })
        }
      }
    })
    getUserintegral(userid).then(res => {

    }).catch(err => {
      that.setData({
        userintegral: err.code
      })
    }),
    getCenterMenu().then(res => {
      console.log('res')
      console.log(res)
    }).catch(err => {
      console.log('err')
      console.log(err)
    })
  },

  methods: {
    onClose(event) {
      const {
        position,
        instance
      } = event.detail;
      switch (position) {
        case 'left':
        case 'cell':
          instance.close();
          break;
        case 'right':
          Dialog.confirm({
            message: '确定删除吗？',
          }).then(() => {
            instance.close();
          });
          break;
      }
    },
    integral() {
      wx.navigateTo({
        url: '/pages/component/self/integral/index'
      })
    }
  }
})